public class demo04 {
    //路径
    public static void main(String[] args) {
        int[] arr=new int[2022];
        for (int i = 1; i <= 2021; i++) {
            arr[i]=Integer.MAX_VALUE;
        }
        arr[1]=0;
        for (int i = 1; i < 2021; i++) {
            for (int j = i+1; j <= 2021&&(j-i<=21); j++) {
                arr[j]=Math.min(arr[j],arr[i]+(i*j/gcd(i,j)));
            }
        }
        System.out.println(arr[2021]);
    }
    private static int gcd(int a,int b){
        int c=a%b;
        while (c!=0){
            a=b;
            b=c;
            c=a%b;
        }
        return b;
    }
}
